package com.example.common.common.config.filter;

import com.example.common.utils.RedisUtils;
import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author qwert
 * @version 1.0.0
 * @create 2025/7/6 16:32
 **/

@Configuration
public class FilterConfig {

    @Bean
    public FilterRegistrationBean<UserInfoFilter> userInfoFilter(RedisUtils redisUtils) {
        FilterRegistrationBean<UserInfoFilter> registration = new FilterRegistrationBean<>();
        registration.setFilter(new UserInfoFilter(redisUtils));
        registration.addUrlPatterns("/*"); // 匹配所有请求
        registration.setOrder(1); // 设置执行顺序
        return registration;
    }
}
